import request from '@/utils/request'


export default{
    getRoleList(searchModel){
        return request({
            url:'/role',
            method:'get',
            params:{
                pageNo: searchModel.pageNo,
                pageSize: searchModel.pageSize,
                username: searchModel.username,
            }
        });
    },
    deleteRoleById(id){
        return request({
            url:`/role/${id}`,
            method:'delete',
        })
    },
    getRoleById(id){
        return request({
            url:`/role/${id}`,
            method:'get',
        })
    },
    saveRole(role){
        if(role.id == null || role.id == undefined){
            return this.addRole(role);
        }else{
            console.log(role)
            return this.updateRole(role);
        }
    },
    addRole(role){
        return request({
            url: '/role',
            method: 'post',
            data: role
        });
    },
    updateRole(role){
        return request({
            url: `/role`,
            method: 'put',
            data: role
        });
    },
}